#!/usr/bin/python

# ----------------- BEGIN LICENSE BLOCK ---------------------------------
#
# Copyright (c) 2019-2020 Intel Corporation
#
# SPDX-License-Identifier: LGPL-2.1-only
#
# ----------------- END LICENSE BLOCK -----------------------------------

"""
This module uses pygccxml and py++ to generate
Python interfaces for all classes and datatypes
of the ad_rss library.

The resulting library is called libad_rss_python
"""

from python_wrapper_helper import generate_python_wrapper, post_process_python_wrapper


def main():
    """
    Main function to generate Python-C++ binding code
    """
    header_dirs = {
        "${CMAKE_CURRENT_LIST_DIR}/../generated/include/",
        "${CMAKE_CURRENT_LIST_DIR}/../impl/include/"
    }
    include_dirs = {
        "${GENPY_INCLUDE_DIRS}"
    }

    generate_python_wrapper(library_name="libad_rss_python",
                            cpp_filename="AdRssPythonWrapper.cpp.in",
                            header_directories=header_dirs,
                            include_paths=include_dirs,
                            declarations={
                                "ad", "toString", "fromString", "std::to_string", "std::sqrt", "std::fabs", "std::numeric_limits"}
                            )

    # these are additional replacements that have to be done...
    additional_replacements = {
        # RoadSegment: vector<vector>>, set name manually, tool doesn't understand correctly
        ("\"vector_less__ad_scope_rss_scope_world_scope_LaneSegment__greater_\"", "\"RoadSegment\"")
    }

    additional_replacements_python2=additional_replacements.copy()
    additional_replacements_python2.add(("libad_rss_python", "libad_rss_python2"))
    post_process_python_wrapper(header_directories=header_dirs,
                                cpp_filename_in="AdRssPythonWrapper.cpp.in",
                                cpp_filename_out="AdRssPythonWrapperPYTHON2.cpp",
                                additional_replacements=additional_replacements_python2,
                                spdx_license="LGPL-2.1-only")

    additional_replacements_python3=additional_replacements.copy()
    additional_replacements_python3.add(("libad_rss_python", "libad_rss_python3"))
    post_process_python_wrapper(header_directories=header_dirs,
                                cpp_filename_in="AdRssPythonWrapper.cpp.in",
                                cpp_filename_out="AdRssPythonWrapperPYTHON3.cpp",
                                additional_replacements=additional_replacements_python3,
                                spdx_license="LGPL-2.1-only")


if __name__ == '__main__':
    main()
